package net.vil.framework.page;

import javax.servlet.http.HttpServletRequest;

import net.vil.framework.util.StringUtil;

public class ExtPagerable implements Pagerable{
	public static final String PAGE_START="start";
	public static final String PAGE_SIZE_NAME="pageSize";
	public static final String DATA_LIMIT="limit";
	public static ExtPagerable extPager=null;
	@Override
	public <T extends Object> void createPagerByParam(HttpServletRequest request,Pager<T> pager,Class<T> cls)
		 {
			int cpage=0;
			int pageSize=15;
			String p1=request.getParameter(PAGE_START);
			String p2=request.getParameter(PAGE_SIZE_NAME);
			String p3=request.getParameter(DATA_LIMIT);
			if (!StringUtil.isEmpty(p2)){
				int psize=Integer.valueOf(p2);
				if (psize>0){
					pageSize=psize;
				}
			}
			if (!StringUtil.isEmpty(p1)){
				cpage=Integer.valueOf(p1).intValue()/pageSize;
			}
			
			if (!StringUtil.isEmpty(p3)){
			}
			pager.initPagerParam(cpage,pageSize);
	}
	private ExtPagerable(){
		
	}
	public static ExtPagerable getInstance(){
		if (extPager==null){
			extPager=new ExtPagerable();
		}
		return extPager;
	}

}
